/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.dat.view;

import bgu.ppm.dat.model.FilterField;

/**
 *
 * @author user
 */
public class FilterFieldSelectableItem extends SelecteableItem<FilterField> {

    public FilterFieldSelectableItem(FilterField ff) {
        super(ff, true);
    }

    @Override
    public void setFromText(String text) {
        getItem().setFieldName(text);
    }

    @Override
    public boolean isSelected() {
        return getItem().getRestrictedValues().isEmpty();
    }

    @Override
    public void setSelected(boolean selected) {
        for (Object v : getItem().getAllValues()) {
            if (selected) {
                getItem().allowValue(v);
            } else {
                getItem().restrictValue(v);
            }
        }
    }
}
